<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MVCWeb.Models.Menu>>" %>

<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Index of Share Menu</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
   <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->

    <script language="javascript" type="text/javascript">
        function deleteRecord(recordId) {
            if (confirm("Are you sure to delete this menu?")) {
                // Perform delete
                var action = '<%= Url.Action("Delete", "Menu") %>/' + recordId;
                var request = new Sys.Net.WebRequest();
                request.set_httpVerb("POST");
                request.set_url(action);
                request.add_completed(deleteCompleted);
                request.invoke();
            }
        }

        function deleteCompleted() {
            // Reload page  
            window.location.reload();
        }    
    </script>

    <br />
    <h2>
        Index of Share Menu</h2>
    <hr />
    <table cellpadding="4" cellspacing="1" border="0" width="100%" class="DataTable">
        <tr>
            <th style="width:100%">
                Menu name
            </th>
            <th style="width:1%">
                Link
            </th>
            <th style="width:1%">
                Type
            </th>
            <th style="width:1%">
            </th>
        </tr>
        <% foreach (var item in Model)
           { %>
        <tr>
            <td>
                <%= item.MenuName %>
            </td>
            <td>
                <%= Html.TextBox("Link", item.Link, new { style = "width:100px" })%>
            </td>
            <td>
                <%= Html.TextBox("Link", item.Type, new { style = "width:100px" })%>
            </td>
            <td style="white-space: nowrap">
                <%= Html.ActionLink("Edit", "Edit", new { id=item.MenuId }) %>
                | <a onclick="deleteRecord(<%= item.MenuId %>)" href="JavaScript:void(0)">Delete </a>
            </td>
        </tr>
        <% } %>
    </table>
    <p>
        <%= Html.ActionLink("Create New Share Menu", "Create") %>
    </p>
</asp:Content>
